package com.sg.business.permission.handler;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.handlers.HandlerUtil;

import com.sg.business.permission.ui.PermissionSettingDialog;

public class PermissionSetting extends AbstractHandler {

	@Override
	public Object execute(ExecutionEvent event) throws ExecutionException {
		IStructuredSelection sel = (IStructuredSelection) HandlerUtil
				.getCurrentSelection(event);
		if (!sel.isEmpty()) {
			String scope = event.getParameter("permission.scope");
			Object element = sel.getFirstElement();
			if (sel != null) {
				PermissionSettingDialog.open(HandlerUtil.getActiveShell(event),
						element, scope);
			}
		}
		return null;
	}

}
